package tech.aistar.corejava.day02;

/**
 * Created by 李雨昂 on 2019/7/16.
 */
@SuppressWarnings("all")
public class SwitchCaseDemo {
    public static void main(String[] args) {
        int year = 2012;
        //定义月份
        int month = 2;
        //定义天数
        int maxDays = 0;

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                maxDays = 31;
                break;
            case 2:
                maxDays = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0) ? 29 : 28;
                break;
            default:
                maxDays = 30;
                break;
        }
        System.out.println(year + "年" + month + "月,最大天数是:" + maxDays);
    }
}
